package com.chinaunicom.create.factory.simplefactory;

import com.chinaunicom.create.factory.Pizza;

import java.util.Arrays;
import java.util.List;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/7/15 11:01
 * Description: 客户端
 */
class Order {
    private PizzaFactory pizzaFactory;
    public Order(PizzaFactory pizzaFactory){
        this.pizzaFactory = pizzaFactory;
    }
    public static void main(String[] args) {

        List<String> data = Arrays.asList("A", "B", "C");


        String type = data.get((int) (System.nanoTime() % data.size()));
        
        PizzaFactory pizzaFactory = new PizzaFactory(type);
        Order client = new Order(pizzaFactory);
        
        Pizza pizza = client.pizzaFactory.createPizza();

        pizza.prepare();
        pizza.make();
        pizza.finish();
    }
}
